package com.echoesnet.echoesshortvideo.Repositories;

import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.MutableLiveData;
import android.text.TextUtils;

import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.baidu.mapapi.model.LatLng;
import com.baidu.mapapi.search.core.PoiInfo;
import com.baidu.mapapi.search.geocode.GeoCodeResult;
import com.baidu.mapapi.search.geocode.GeoCoder;
import com.baidu.mapapi.search.geocode.OnGetGeoCoderResultListener;
import com.baidu.mapapi.search.geocode.ReverseGeoCodeOption;
import com.baidu.mapapi.search.geocode.ReverseGeoCodeResult;
import com.baidu.mapapi.search.poi.OnGetPoiSearchResultListener;
import com.baidu.mapapi.search.poi.PoiCitySearchOption;
import com.baidu.mapapi.search.poi.PoiDetailResult;
import com.baidu.mapapi.search.poi.PoiIndoorResult;
import com.baidu.mapapi.search.poi.PoiResult;
import com.baidu.mapapi.search.poi.PoiSearch;
import com.echoesnet.echoesshortvideo.AppController;
import com.orhanobut.logger.Logger;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

/**
 * Copyright (C) 2017 在线回声（天津）科技发展有限公司
 * 在线回声完全享有此软件的著作权，违者必究
 *
 * @author an
 * @version 1.0
 * @modifier
 * @createDate 2018/4/25 0025
 * @description
 */
public class SearchLocationRepository
{
    private final static String TAG = SearchLocationRepository.class.getSimpleName();

    private PoiSearch mPoiSearch;

    public void init(OnGetPoiSearchResultListener onGetPoiSearchResultListener){
        if (mPoiSearch == null)
        {
            mPoiSearch = PoiSearch.newInstance();
        }
        mPoiSearch.setOnGetPoiSearchResultListener(onGetPoiSearchResultListener);
    }



    public void searchLocation(String city, String keywords, int pageNum){

        if (TextUtils.isEmpty(city))
            city = "天津";
        try
        {
            Logger.t(TAG).d(keywords + "|" + city + "|" + pageNum);
            mPoiSearch.searchInCity(new PoiCitySearchOption().keyword(keywords).city(city).pageNum(pageNum));
        } catch (Exception e)
        {
            Logger.t(TAG).d(e.getMessage());
        }
    }

    public void onDestroy()
    {
        if (mPoiSearch != null)
            mPoiSearch.destroy();
    }
}
